﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace DockSample
{

    class Axis
    {
        protected List<Point> pointList = new List<Point>();
        Pen pen = new Pen(Color.Blue, 1);
        public Axis()
        {
            pointList.Add(new Point(50, 150));
            pointList.Add(new Point(50, 280));
            pointList.Add(new Point(20, 250));
            pointList.Add(new Point(350, 250));
        }

        public void draw(Graphics g)
        {
            for (int i = 0; i < pointList.Count; i += 2)
            {
                g.DrawLine(pen, pointList[i], pointList[i + 1]);
            }
        }
    }

    public class OriginalNFRChartType
    {
        public  OriginalNFRChartType()
        {
            this.id = System.Guid.NewGuid().ToString();
        }
//         public virtual OriginalNFRChartType(string id)
//         {
//             this.id = id;
//         }
          
        public string id;
        //new
        public List<NFRChartPoint> pointList = new List<NFRChartPoint>();
        protected Pen pen = new Pen(Color.Blue, 1);

        protected double xAxisLength = 200;
        //new
        protected double x1 = -1;

        public double X1
        {
            get { return x1; }
            set { x1 = value; }
        }
        //new
        protected double x2 = -1;
        public double X2
        {
            get { return x2; }
            set { x2 = value; }
        }
        //new
        protected double x3 = -1;
        public double X3
        {
            get { return x3; }
            set { x3 = value; }
        }

        public virtual void adjustChart()
        {

        }
        //魔数为微调坐标显示位置
        int labelHeight = 15;
        public virtual Point getFirstLabelLocation()
        {
            return new Point(pointList[1].point.X - labelHeight, pointList[1].point.Y - labelHeight);
        }

        public virtual Point getSecondLabelLocation()
        {
            return new Point(pointList[3].point.X - labelHeight, pointList[3].point.Y + 2);
        }

        public virtual Point getThirdLabelLocation()
        {
            return pointList[5].point;
        }

        public virtual string getChartType()
        {
            return null;
        }

        public void draw(Graphics g)
        {
            for (int i = 0; i < pointList.Count; i += 2)
            {
                g.DrawLine(pen, pointList[i].point, pointList[i + 1].point);
            }
        }
    }
    //
    class TypeOne : OriginalNFRChartType
    {
        public TypeOne():base()
        {
            pointList.Add(new NFRChartPoint(new Point(50, 250)));
            pointList.Add(new NFRChartPoint(new Point(100, 200)));
            pointList.Add(new NFRChartPoint(new Point(100, 200)));
            pointList.Add(new NFRChartPoint(new Point(250, 200)));
        }
        public TypeOne(int x)
            :this()
        {
            this.x1 = x;
        }

        public override void adjustChart()
        {

        }

        public override string getChartType()
        {
            return "TypeOne";
        }
    }
    //
    class TypeTwo : OriginalNFRChartType
    {
        public TypeTwo()
            : base()
        {
            pointList.Add(new NFRChartPoint(new Point(50, 250)));
            pointList.Add(new NFRChartPoint(new Point(150, 200)));
            pointList.Add(new NFRChartPoint(new Point(150, 200)));
            pointList.Add(new NFRChartPoint(new Point(250, 250)));
        }
        public TypeTwo(int x1, int x2)
            :this()
        {
            this.x1 = x1;
            this.x2 = x2;
        }

        public override string getChartType()
        {
            return "TypeTwo";
        }

        public override void adjustChart()
        {
            double tmp = xAxisLength / x2;

            pointList[1] = new NFRChartPoint(new Point(50 + (int)(tmp * x1), 200));
            pointList[2] = new NFRChartPoint(new Point(50 + (int)(tmp * x1), 200));
            pointList[3] = new NFRChartPoint(new Point(50 + (int)(tmp * x2), 250));
        }
    }
    //
    class TypeThree : OriginalNFRChartType
    {
        public TypeThree()
            : base()
        {
            pointList.Add(new NFRChartPoint(new Point(50, 200)));
            pointList.Add(new NFRChartPoint(new Point(150, 200)));
            pointList.Add(new NFRChartPoint(new Point(150, 200)));
            pointList.Add(new NFRChartPoint(new Point(250, 250)));
        }
        public TypeThree(int x1, int x2)
            :this()
        {
            this.x1 = x1;
            this.x2 = x2;
        }

        public override void adjustChart()
        {
            double tmp = xAxisLength / x2;

            pointList[1] = new NFRChartPoint(new Point(50 + (int)(tmp * x1), 200));
            pointList[2] = new NFRChartPoint(new Point(50 + (int)(tmp * x1), 200));
            pointList[3] = new NFRChartPoint(new Point(50 + (int)(tmp * x2), 250));
        }
        public override string getChartType()
        {
            return "TypeThree";
        }
    }
    //
    class TypeFour : OriginalNFRChartType
    {
        public TypeFour()
            : base()
        {
            pointList.Add(new NFRChartPoint(new Point(100, 250)));
            pointList.Add(new NFRChartPoint(new Point(150, 200)));
            pointList.Add(new NFRChartPoint(new Point(150, 200)));
            pointList.Add(new NFRChartPoint(new Point(250, 200)));
        }
        public TypeFour(int x1, int x2)
            : this()
        {
            this.x1 = x1;
            this.x2 = x2;
        }

        int labelHeight = 15;

        public override  Point getFirstLabelLocation()
        {
            return new Point(pointList[0].point.X - labelHeight, pointList[0].point.Y + 2);
        }

        public override Point getSecondLabelLocation()
        {
            return new Point(pointList[1].point.X - labelHeight, pointList[1].point.Y - labelHeight);
        }

        public override string getChartType()
        {
            return "TypeFour";
        }

        public override void adjustChart()
        {
            double tmp = 150 / x2;

            pointList[0] = new NFRChartPoint(new Point(50 + (int)(tmp * x1), 250));
            pointList[1] = new NFRChartPoint(new Point(50 + (int)(tmp * x2), 200));
            pointList[2] = new NFRChartPoint(new Point(50 + (int)(tmp * x2), 200));
        }
    }
    //
    class TypeFive : OriginalNFRChartType
    {
        public TypeFive()
            : base()
        {
            pointList.Add(new NFRChartPoint(new Point(100, 250)));
            pointList.Add(new NFRChartPoint(new Point(100, 200)));
            pointList.Add(new NFRChartPoint(new Point(100, 200)));
            pointList.Add(new NFRChartPoint(new Point(250, 200)));
        }
        public TypeFive(int x1)
            : this()
        {
            this.x1 = x1;
        }

        int labelHeight = 15;

        public override Point getFirstLabelLocation()
        {
            return new Point(pointList[1].point.X - labelHeight, pointList[1].point.Y - labelHeight);
        }

        public override string getChartType()
        {
            return "TypeFive";
        }

    }
    //
    class TypeSix : OriginalNFRChartType
    {
        public TypeSix()
            : base()
        {
            pointList.Add(new NFRChartPoint(new Point(50, 200)));
            pointList.Add(new NFRChartPoint(new Point(150, 200)));
            pointList.Add(new NFRChartPoint(new Point(150, 200)));
            pointList.Add(new NFRChartPoint(new Point(150, 250)));
        }
        public TypeSix(int x1)
            : this()
        {
            this.x1 = x1;
        }

        int labelHeight = 15;

        public override Point getFirstLabelLocation()
        {
            return new Point(pointList[1].point.X - labelHeight, pointList[1].point.Y - labelHeight);
        }

        public override string getChartType()
        {
            return "TypeSix";
        }

    }
    //
    class TypeSeven : OriginalNFRChartType
    {
        public TypeSeven()
            : base()
        {
            pointList.Add(new NFRChartPoint(new Point(50, 250)));
            pointList.Add(new NFRChartPoint(new Point(100, 200)));
            pointList.Add(new NFRChartPoint(new Point(100, 200)));
            pointList.Add(new NFRChartPoint(new Point(200, 200)));
            pointList.Add(new NFRChartPoint(new Point(200, 200)));
            pointList.Add(new NFRChartPoint(new Point(250, 250)));
        }
        public TypeSeven(int x1,int x2, int x3)
            : this()
        {
            this.x1 = x1;
            this.x2 = x2;
            this.x3 = x3;
        }

        int labelHeight = 15;

        public override Point getFirstLabelLocation()
        {
            return new Point(pointList[1].point.X - labelHeight, pointList[1].point.Y - labelHeight);
        }

        public override Point getSecondLabelLocation()
        {
            return new Point(pointList[3].point.X - labelHeight, pointList[3].point.Y - labelHeight);
        }

        public override Point getThirdLabelLocation()
        {
            return new Point(pointList[5].point.X - labelHeight, pointList[5].point.Y + 2);
        }

        public override void adjustChart()
        {
            double tmp = xAxisLength / x3;

            pointList[1] = new NFRChartPoint(new Point(50 + (int)(tmp * x1), 200));
            pointList[2] = new NFRChartPoint(new Point(50 + (int)(tmp * x1), 200));
            pointList[3] = new NFRChartPoint(new Point(50 + (int)(tmp * x2), 200));
            pointList[4] = new NFRChartPoint(new Point(50 + (int)(tmp * x2), 200));
            pointList[5] = new NFRChartPoint(new Point(50 + (int)(tmp * x3), 250));
        }

        public override string getChartType()
        {
            return "TypeSeven";
        }
    }
}
